//
//  XSPPageControl.m
//  Xspcf
//
//  Created by 赵欢 on 2017/12/1.
//  Copyright © 2017年 小小算盘. All rights reserved.
//

#import "XSPPageControl.h"
@implementation XSPPageControl
#define dotW 10
#define magrin 5
- (void)layoutSubviews
{
    [super layoutSubviews];
    [self changePageControlSize];
}
- (void) changePageControlSize {
    CGFloat marginX = dotW + magrin;
    for (int i=0; i<[self.subviews count]; i++) {
        UIImageView* dot = [self.subviews objectAtIndex:i];
        if (i == self.currentPage) {
            [dot setFrame:CGRectMake(i * marginX, dot.frame.origin.y, dotW*3, dotW)];
        }else if (i <= self.currentPage){
            [dot setFrame:CGRectMake(i * marginX, dot.frame.origin.y, dotW, dotW)];
        }else{
            [dot setFrame:CGRectMake(i * marginX + dotW*2, dot.frame.origin.y, dotW, dotW)];
        }
    }
}
- (void) setCurrentPage:(NSInteger)page {
    [super setCurrentPage:page];
    [self changePageControlSize];
}
@end
